//package com.jhhc.EngineeringSafety;
//
//
//
//import com.alibaba.fastjson2.JSONObject;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.BDMS_ES_FORECASTOBJ_B;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.ForecastBaseInfo;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.ForecastItem;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.MonitorStation;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.Point;
//import com.jhhc.EngineeringSafety.BaseInfo.service.BDMS_ES_FORECASTOBJ_BService;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.BDMS_CALCULATESCHEME_M;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.BDMS_YB_RESULT_M;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.param.RunParam;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.result.CalData;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.result.CalResult;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.result.CalSchemeInfo;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.result.ModelData;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.result.RunResult;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.result.ValueModelC;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.entity.result.ValueModelP;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.service.BDMS_CALCULATESCHEME_M33Service;
//import com.jhhc.EngineeringSafety.Calculate.Forecast.service.BDMS_YB_RESULT_M3Service;
//import com.jhhc.RHDB.Data.Pojo.Data;
//import com.jhhc.utils.JsonResult;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import java.text.DecimalFormat;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Calendar;
//import java.util.Comparator;
//import java.util.Date;
//import java.util.GregorianCalendar;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//import java.util.Random;
//import java.util.stream.Collectors;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//@Api(value = "EngineeringSafetyCalculateController", tags = {"预报计算服务"})
//@RequestMapping(value = {"EngineeringSafety/Calculate/Forecast"}, headers = {"Accept=application/json"})
//@RestController("EngineeringSafetyCalculateController")
//public class CalculateController {
//    @Autowired
//    private BDMS_CALCULATESCHEME_M33Service bdms_calculatescheme_mService;
//
//    @Autowired
//    private BDMS_ES_FORECASTOBJ_BService bdms_es_forecastobj_bService;
//
//    @Autowired
//    private BDMS_YB_RESULT_M3Service bdms_yb_result_m3Service;
//
//    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//    Calendar calendar = new GregorianCalendar();
//
//    @ApiOperation("")
//    @RequestMapping(value = {"RunByDisplacement"}, headers = {"Accept=application/json"}, method = {RequestMethod.POST})
//    public JsonResult runByDisplacement(@RequestBody RunParam runParam) throws ParseException {
//        JsonResult jsonResult = new JsonResult();
//        RunResult result = new RunResult();
//        BDMS_CALCULATESCHEME_M bdms_calculatescheme_m = new BDMS_CALCULATESCHEME_M();
//        bdms_calculatescheme_m.setCschemeid(runParam.getCalSchemeId());
//        bdms_calculatescheme_m.setDtmforecast(runParam.getForecastTime());
//        bdms_calculatescheme_m.setDtmstart(runParam.getForecastBeginTime());
//        this.calendar.setTime(this.format.parse(runParam.getForecastTime()));
//        this.calendar.add(Calendar.HOUR, runParam.getCalTimeSpan());
//        bdms_calculatescheme_m.setDtmend(this.format.format(this.calendar.getTime()));
//        bdms_calculatescheme_m.setFschemeid(String.valueOf(runParam.getMonitorTypeId()));
//        bdms_calculatescheme_m.setPid(runParam.getProjectId());
//        bdms_calculatescheme_m.setDtmcalculate(this.format.format(new Date()));
//        bdms_calculatescheme_m.setUserid(runParam.getUserId());
//        BDMS_CALCULATESCHEME_M bdmsCalculateschemeM = this.bdms_calculatescheme_mService.seletcById(runParam.getProjectId(), runParam.getCalSchemeId());
//        System.out.println("ku"+ bdmsCalculateschemeM);
//        if (bdmsCalculateschemeM == null) {
//            this.bdms_calculatescheme_mService.insert(bdms_calculatescheme_m);
//            List<BDMS_ES_FORECASTOBJ_B> bdms_es_forecastobj_bs = bdms_es_forecastobj_bService.queryAllByForeCastId(runParam.getForecastObjectId(), runParam.getMonitorTypeId());
//            List<ForecastBaseInfo> forecastBaseInfos = new ArrayList<>();
//            Map<String, List<BDMS_ES_FORECASTOBJ_B>> typeListGroup = bdms_es_forecastobj_bs.stream().collect(Collectors.groupingBy(BDMS_ES_FORECASTOBJ_B::getObjforecast, Collectors.toList()));
//            for (Map.Entry<String, List<BDMS_ES_FORECASTOBJ_B>> typeList : typeListGroup.entrySet()) {
//                ForecastBaseInfo forecastBaseInfo = new ForecastBaseInfo();
//                List<ForecastItem> forecastItems = new ArrayList<>();
//                forecastBaseInfo.setForecastObject(typeList.getKey());
//                Map<String, List<BDMS_ES_FORECASTOBJ_B>> motypeListGroup = (Map<String, List<BDMS_ES_FORECASTOBJ_B>>)((List)typeList.getValue()).stream().collect(Collectors.groupingBy(BDMS_ES_FORECASTOBJ_B::getMonitortype, Collectors.toList()));
//                for (Map.Entry<String, List<BDMS_ES_FORECASTOBJ_B>> motypeList : motypeListGroup.entrySet()) {
//                    ForecastItem forecastItem = new ForecastItem();
//                    List<MonitorStation> monitorStations = new ArrayList<>();
//                    forecastItem.setMonitorType(motypeList.getKey());
//                    forecastItem.setMonitorTypeId(((BDMS_ES_FORECASTOBJ_B)Objects.<BDMS_ES_FORECASTOBJ_B>requireNonNull(((List<BDMS_ES_FORECASTOBJ_B>)typeList.getValue()).stream().filter(bdms_es_forecastobj_b -> bdms_es_forecastobj_b.getMonitortype().equals(motypeList.getKey())).findAny().orElse(null))).getMonitortypeid());
//                    Map<String, List<BDMS_ES_FORECASTOBJ_B>> staListGroup = (Map<String, List<BDMS_ES_FORECASTOBJ_B>>)((List)motypeList.getValue()).stream().collect(Collectors.groupingBy(BDMS_ES_FORECASTOBJ_B::getStcd, Collectors.toList()));
//                    for (Map.Entry<String, List<BDMS_ES_FORECASTOBJ_B>> staList : staListGroup.entrySet()) {
//                        MonitorStation monitorStation = new MonitorStation();
//                        List<Point> points = new ArrayList<>();
//                        monitorStation.setStationCode(staList.getKey());
//                        for (BDMS_ES_FORECASTOBJ_B bdms_es_forecastobj_b : staList.getValue()) {
//                            Point point = new Point();
//                            point.setMonitorName(bdms_es_forecastobj_b.getMonitorname());
//                            point.setMonitorXY(bdms_es_forecastobj_b.getMonitorxy());
//                            point.setMonitorId(bdms_es_forecastobj_b.getMonitorid());
//                            point.setMonitorCode(bdms_es_forecastobj_b.getMonitorcode());
//                            forecastBaseInfo.setForecastObjectId(bdms_es_forecastobj_b.getObjforecastid());
//                            monitorStation.setStationName(bdms_es_forecastobj_b.getStnm());
//                            points.add(point);
//                        }
//                        monitorStation.setPoints(points);
//                        monitorStations.add(monitorStation);
//                    }
//                    forecastItem.setStations(monitorStations);
//                    forecastItems.add(forecastItem);
//                }
//                forecastBaseInfo.setForecastItems(forecastItems);
//                forecastItems.sort(Comparator.comparing(ForecastItem::getMonitorTypeId));
//                forecastBaseInfos.add(forecastBaseInfo);
//            }
//            CalResult calResult = RUN(bdms_calculatescheme_m.getCschemeid(), ((ForecastBaseInfo)forecastBaseInfos.get(0)).getForecastItems().get(0));
//            result.setCalSchemeInfo(calResult.getCalSchemeInfo());
//            if (runParam.isHasResult())
//                result.setCalResult(calResult.getCalResult());
//            jsonResult.setData(result);
//            jsonResult.setSucceeded(true);
//            jsonResult.setStatusCode(Integer.valueOf(200));
//        } else {
//            jsonResult.setData("已存在此条计算方案，请更换计算方案编号");
//            jsonResult.setSucceeded(true);
//            jsonResult.setStatusCode(Integer.valueOf(200));
//        }
//        return jsonResult;
//    }
//
//    public CalResult RUN(String calId, ForecastItem forecastItem) throws ParseException {
//        CalResult calResult = new CalResult();
//        List<ValueModelP> valueModelPS = new ArrayList<>();
//        DecimalFormat a1 = new DecimalFormat("00000000");
//        BDMS_CALCULATESCHEME_M bdms_calculatescheme_m = this.bdms_calculatescheme_mService.queryByCalId(calId);
//        System.out.println("chaxun:" + bdms_calculatescheme_m);
//        if (bdms_calculatescheme_m != null) {
//            CalSchemeInfo calSchemeInfo = new CalSchemeInfo();
//            calSchemeInfo.setCalSchemeId(bdms_calculatescheme_m.getCschemeid());
//            if (bdms_calculatescheme_m.getAliasnm() != null) {
//                calSchemeInfo.setCalSchemeName(bdms_calculatescheme_m.getAliasnm());
//            } else {
//                calSchemeInfo.setCalSchemeName(bdms_calculatescheme_m.getCschemenm());
//            }
//            calSchemeInfo.setForecastTime(bdms_calculatescheme_m.getDtmforecast().substring(0, 19));
//            calSchemeInfo.setOperateTime(bdms_calculatescheme_m.getDtmcalculate().substring(0, 19));
//            if (bdms_calculatescheme_m.getState() != null)
//                switch (bdms_calculatescheme_m.getState().intValue()) {
//                    case 0:
//                        calSchemeInfo.setStateInfo("新建方案");
//                        break;
//                    case 1:
//                        calSchemeInfo.setStateInfo("计算中");
//                        break;
//                    case 2:
//                        calSchemeInfo.setStateInfo("计算失败");
//                        break;
//                    case 3:
//                        calSchemeInfo.setStateInfo("计算完成");
//                        break;
//                }
//            calSchemeInfo.setState(bdms_calculatescheme_m.getState());
//            calSchemeInfo.setUserId(String.valueOf(bdms_calculatescheme_m.getUserid()));
//            calSchemeInfo.setForecastBeginTime(bdms_calculatescheme_m.getDtmstart().substring(0, 19));
//            calSchemeInfo.setForecastEndTime(bdms_calculatescheme_m.getDtmend().substring(0, 19));
//            calSchemeInfo.setDescription(bdms_calculatescheme_m.getRemark());
//            calResult.setCalSchemeInfo(calSchemeInfo);
//            Date date1 = this.format.parse(bdms_calculatescheme_m.getDtmforecast());
//            Date date2 = this.format.parse(bdms_calculatescheme_m.getDtmend());
//            Date date3 = this.format.parse(bdms_calculatescheme_m.getDtmstart());
//            int hourAll = Integer.parseInt(String.valueOf((date2.getTime() - date3.getTime()) / 3600000L));
//            int hourF = Integer.parseInt(String.valueOf((date2.getTime() - date1.getTime()) / 3600000L));
//            int hourM = Integer.parseInt(String.valueOf((date1.getTime() - date3.getTime()) / 3600000L));
//            List<CalData> calDatas = new ArrayList<>();
//            for (MonitorStation station : forecastItem.getStations()) {
//                CalData calData = new CalData();
//                calData.setMainHeading(station.getStationName() + "(" + station.getStationCode() + ")" + forecastItem.getMonitorType() + "风险预报");
//                calData.setSubHeading("作业预报时间"+ bdms_calculatescheme_m.getDtmforecast().substring(0, 19) + "预报根据时间：" + bdms_calculatescheme_m.getDtmstart().substring(0, 19) + "--" + bdms_calculatescheme_m
//                        .getDtmforecast().substring(0, 19));
//                calData.setForecastStationCode(station.getStationCode());
//                calData.setStationCode(station.getStationCode());
//                this.calendar.setTime(this.format.parse(bdms_calculatescheme_m.getDtmforecast()));
//                this.calendar.add(Calendar.HOUR, 1);
//                String forecast = this.format.format(this.calendar.getTime());
//                for (Point point : station.getPoints()) {
//                    ValueModelP valueModeP = new ValueModelP();
//                    valueModeP.setMonitorName(point.getMonitorName());
//                    valueModeP.setMonitorId(point.getMonitorId());
//                    valueModeP.setMonitorXY(point.getMonitorXY());
//                    valueModeP.setMonitorCode(point.getMonitorCode());
//                    ValueModelC valueModelC = new ValueModelC();
//                    valueModelC.setUnit("mm");
//                    valueModelC.setCalDataType(forecastItem.getMonitorType());
//                    valueModelC.setValueName(forecastItem.getMonitorType());
//                    valueModelC.setOrder(1);
//                    List<ModelData> modelDatas = new ArrayList<>();
//                    String[] dttps = { "模拟","预报"};
//                    double min = 35.0D;
//                    double max = 44.0D;
//                    StringBuilder dmn = new StringBuilder();
//                    StringBuilder dyb = new StringBuilder();
//                    BDMS_YB_RESULT_M bdmsYbResultM = new BDMS_YB_RESULT_M();
//                    bdmsYbResultM.setCschemeid(calId);
//                    bdmsYbResultM.setStcd(station.getStationCode());
//                    bdmsYbResultM.setDType(Integer.parseInt(forecastItem.getMonitorTypeId()));
//                    bdmsYbResultM.setDatacode(point.getMonitorCode());
//                    for (String dttp : dttps) {
//                        ModelData modelData;
//                        List<Data> dataList;
//                        int i;
//                        Data maxData;
//                        Data minData;
//                        ModelData modelDataY;
//                        List<Data> dataListY;
//                        int j;
//                        Data maxDataF;
//                        Data minDataF;
//                        switch (dttp) {
//                            case "模拟":
//                                modelData = new ModelData();
//                                modelData.setDataType(dttps[0] + forecastItem.getMonitorType());
//                                dataList = new ArrayList<>();
//                                for (i = 0; i < hourM + 1; i++) {
//                                    this.calendar.setTime(date3);
//                                    this.calendar.add(10, i);
//                                    Data data = new Data();
//                                    data.setTM(this.format.format(this.calendar.getTime()));
//                                    Random random = new Random();
//                                    double randomNumber = min + (max - min) * random.nextDouble();
//                                    double roundedNumber = Math.round(randomNumber * 10000.0D) / 10000.0D;
//                                    dmn.append(roundedNumber).append(",");
//                                    data.setValue(roundedNumber);
//                                    dataList.add(data);
//                                }
//                                maxData = dataList.stream().max(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                minData = dataList.stream().min(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                modelData.setMaxValue(maxData.getValue());
//                                modelData.setMaxTm(maxData.getTM());
//                                modelData.setMinValue(minData.getValue());
//                                modelData.setMinTm(minData.getTM());
//                                modelData.setValues(dataList);
//                                modelDatas.add(modelData);
//                                break;
//                            case "预报":
//                                modelDataY = new ModelData();
//                                modelDataY.setDataType(dttps[1] + forecastItem.getMonitorType());
//                                dataListY = new ArrayList<>();
//                                for (j = 1; j < hourF + 1; j++) {
//                                    this.calendar.setTime(date1);
//                                    this.calendar.add(10, j);
//                                    Data data = new Data();
//                                    data.setTM(this.format.format(this.calendar.getTime()));
//                                    Random random = new Random();
//                                    double randomNumber = min + (max - min) * random.nextDouble();
//                                    double roundedNumber = Math.round(randomNumber * 10000.0D) / 10000.0D;
//                                    data.setValue(roundedNumber);
//                                    dataListY.add(data);
//                                    dyb.append(roundedNumber).append(",");
//                                }
//                                maxDataF = dataListY.stream().max(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                minDataF = dataListY.stream().min(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                modelDataY.setMaxValue(maxDataF.getValue());
//                                modelDataY.setMaxTm(maxDataF.getTM());
//                                modelDataY.setMinValue(minDataF.getValue());
//                                modelDataY.setMinTm(minDataF.getTM());
//                                modelDataY.setValues(dataListY);
//                                modelDatas.add(modelDataY);
//                                break;
//                                default:
//                                    break;
//                        }
//                    }
//                    bdmsYbResultM.setDMn(dmn.toString());
//                    bdmsYbResultM.setDYb(dyb.toString());
//                    System.out.println("bdmsYbResultM:" + bdmsYbResultM);
//                    this.bdms_yb_result_m3Service.insert(bdmsYbResultM);
//                    valueModelC.setValueDatas(modelDatas);
//                    valueModeP.setValueModels(valueModelC);
//                    valueModelPS.add(valueModeP);
//                }
//                calData.setCalResults(valueModelPS);
//                calDatas.add(calData);
//            }
//            calResult.setCalResult(calDatas);
//        }
//        return calResult;
//    }
//
//    @ApiOperation("获取计算结果")
//    @RequestMapping(value = {"GetCalResult"}, headers = {"Accept=application/json"}, method = {RequestMethod.POST})
//    public JsonResult getCalResult(@RequestBody JSONObject jsonObject) throws ParseException {
//        List<String> calSchemeIds = jsonObject.getList("calSchemeIds", String.class, new com.alibaba.fastjson2.JSONReader.Feature[0]);
//        List<CalResult> calResults = new ArrayList<>();
//        List<String> forecastStationCodes = jsonObject.getList("forecastStationCodes", String.class, new com.alibaba.fastjson2.JSONReader.Feature[0]);
//        JsonResult jsonResult = new JsonResult();
//        for (String calId : calSchemeIds) {
//            CalResult calResult = new CalResult();
//            List<ValueModelP> valueModelPS = new ArrayList<>();
//            BDMS_CALCULATESCHEME_M bdms_calculatescheme_m = this.bdms_calculatescheme_mService.queryByCalId(calId);
//            if (bdms_calculatescheme_m != null) {
//                CalSchemeInfo calSchemeInfo = new CalSchemeInfo();
//                calSchemeInfo.setCalSchemeId(bdms_calculatescheme_m.getCschemeid());
//                if (bdms_calculatescheme_m.getAliasnm() != null) {
//                    calSchemeInfo.setCalSchemeName(bdms_calculatescheme_m.getAliasnm());
//                } else {
//                    calSchemeInfo.setCalSchemeName(bdms_calculatescheme_m.getCschemenm());
//                }
//                calSchemeInfo.setForecastTime(bdms_calculatescheme_m.getDtmforecast().substring(0, 19));
//                calSchemeInfo.setOperateTime(bdms_calculatescheme_m.getDtmcalculate().substring(0, 19));
//                if (bdms_calculatescheme_m.getState() != null)
//                    switch (bdms_calculatescheme_m.getState().intValue()) {
//                        case 0:
//                            calSchemeInfo.setStateInfo("新建方案");
//                            break;
//                        case 1:
//                            calSchemeInfo.setStateInfo("计算中");
//                            break;
//                        case 2:
//                            calSchemeInfo.setStateInfo("计算失败");
//                            break;
//                        case 3:
//                            calSchemeInfo.setStateInfo("计算完成");
//                            break;
//                    }
//                calSchemeInfo.setState(bdms_calculatescheme_m.getState());
//                calSchemeInfo.setUserId(String.valueOf(bdms_calculatescheme_m.getUserid()));
//                calSchemeInfo.setForecastBeginTime(bdms_calculatescheme_m.getDtmstart().substring(0, 19));
//                calSchemeInfo.setForecastEndTime(bdms_calculatescheme_m.getDtmend().substring(0, 19));
//                calSchemeInfo.setDescription(bdms_calculatescheme_m.getRemark());
//                calResult.setCalSchemeInfo(calSchemeInfo);
//                List<CalData> calDatas = new ArrayList<>();
//                List<BDMS_YB_RESULT_M> bdms_yb_result_ms = this.bdms_yb_result_m3Service.searchAllByCschemeid(calId, forecastStationCodes, Integer.valueOf(Integer.parseInt(bdms_calculatescheme_m.getFschemeid())));
//                ForecastItem forecastItem = new ForecastItem();
//                List<MonitorStation> monitorStations = new ArrayList<>();
//                Map<String, List<BDMS_YB_RESULT_M>> typeListGroup = (Map<String, List<BDMS_YB_RESULT_M>>)bdms_yb_result_ms.stream().collect(Collectors.groupingBy(BDMS_YB_RESULT_M::getStcd, Collectors.toList()));
//                for (Map.Entry<String, List<BDMS_YB_RESULT_M>> stcds : typeListGroup.entrySet()) {
//                    MonitorStation monitorStation = new MonitorStation();
//                    List<Point> points = new ArrayList<>();
//                    for (BDMS_YB_RESULT_M bdms_yb_result_m : bdms_yb_result_ms) {
//                        BDMS_ES_FORECASTOBJ_B bdms_es_forecastobj_b = this.bdms_es_forecastobj_bService.queryAllByForeCastIdinSTCD(bdms_yb_result_m.getDType(), bdms_yb_result_m.getDatacode());
//                        forecastItem.setMonitorType(bdms_es_forecastobj_b.getMonitortype());
//                        forecastItem.setMonitorTypeId(bdms_es_forecastobj_b.getMonitortypeid());
//                        Point point = new Point();
//                        point.setMonitorName(bdms_es_forecastobj_b.getMonitorname());
//                        point.setMonitorXY(bdms_es_forecastobj_b.getMonitorxy());
//                        point.setMonitorId(bdms_es_forecastobj_b.getMonitorid());
//                        point.setMonitorCode(bdms_es_forecastobj_b.getMonitorcode());
//                        monitorStation.setStationCode(bdms_es_forecastobj_b.getStcd());
//                        monitorStation.setStationName(bdms_es_forecastobj_b.getStnm());
//                        points.add(point);
//                    }
//                    monitorStation.setPoints(points);
//                    monitorStations.add(monitorStation);
//                }
//                forecastItem.setStations(monitorStations);
//                System.out.println(bdms_yb_result_ms);
//                Date date1 = this.format.parse(bdms_calculatescheme_m.getDtmforecast());
//                Date date2 = this.format.parse(bdms_calculatescheme_m.getDtmend());
//                Date date3 = this.format.parse(bdms_calculatescheme_m.getDtmstart());
//                for (MonitorStation station : forecastItem.getStations()) {
//                    if (station != null) {
//                        CalData calData = new CalData();
//                        calData.setMainHeading(station.getStationName() + "(" + station.getStationCode() + ")" + forecastItem.getMonitorType() + "风险预报");
//                        calData.setSubHeading("作业预报时间"+ bdms_calculatescheme_m.getDtmforecast().substring(0, 19) + "预报根据时间：" + bdms_calculatescheme_m.getDtmstart().substring(0, 19) + "--" + bdms_calculatescheme_m
//                                .getDtmforecast().substring(0, 19));
//                        calData.setForecastStationCode(station.getStationCode());
//                        calData.setStationCode(station.getStationCode());
//                        this.calendar.setTime(this.format.parse(bdms_calculatescheme_m.getDtmforecast()));
//                        this.calendar.add(10, 1);
//                        String forecast = this.format.format(this.calendar.getTime());
//                        for (Point point : station.getPoints()) {
//                            ValueModelP valueModeP = new ValueModelP();
//                            valueModeP.setMonitorName(point.getMonitorName());
//                            valueModeP.setMonitorId(point.getMonitorId());
//                            valueModeP.setMonitorXY(point.getMonitorXY());
//                            valueModeP.setMonitorCode(point.getMonitorCode());
//                            ValueModelC valueModelC = new ValueModelC();
//                            valueModelC.setUnit("mm");
//                            valueModelC.setCalDataType(forecastItem.getMonitorType());
//                            valueModelC.setValueName(forecastItem.getMonitorType());
//                            valueModelC.setOrder(Integer.valueOf(1));
//                            List<ModelData> modelDatas = new ArrayList<>();
//                            String[] dttps = { "模拟","预报"};
//                            StringBuilder dmn = new StringBuilder();
//                            StringBuilder dyb = new StringBuilder();
//                            for (String dttp : dttps) {
//                                ModelData modelData;
//                                BDMS_YB_RESULT_M bdmsYbResultM;
//                                List<Data> dataList;
//                                String[] mns;
//                                int i;
//                                Data maxData;
//                                Data minData;
//                                ModelData modelDataY;
//                                List<Data> dataListY;
//                                BDMS_YB_RESULT_M bdmsYbResultMY;
//                                String[] ybs;
//                                int j;
//                                Data maxDataF;
//                                Data minDataF;
//                                switch (dttp) {
//                                    case "模拟":
//                                        modelData = new ModelData();
//                                        modelData.setDataType(dttps[0] + forecastItem.getMonitorType());
//                                        bdmsYbResultM = bdms_yb_result_ms.stream().filter(bdms_yb_result_m -> bdms_yb_result_m.getDatacode().equals(point.getMonitorCode())).findAny().orElse(null);
//                                        System.out.println(point.getMonitorCode());
//                                        System.out.println("bdmsYbResultM" + bdmsYbResultM);
//                                        dataList = new ArrayList<>();
//                                        mns = bdmsYbResultM.getDMn().split(",");
//                                        for (i = 0; i < mns.length; i++) {
//                                            this.calendar.setTime(date3);
//                                            this.calendar.add(10, i);
//                                            Data data = new Data();
//                                            data.setTM(this.format.format(this.calendar.getTime()));
//                                            data.setValue(Double.valueOf(mns[i]));
//                                            dataList.add(data);
//                                        }
//                                        maxData = dataList.stream().max(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                        minData = dataList.stream().min(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                        modelData.setMaxValue(maxData.getValue());
//                                        modelData.setMaxTm(maxData.getTM());
//                                        modelData.setMinValue(minData.getValue());
//                                        modelData.setMinTm(minData.getTM());
//                                        modelData.setValues(dataList);
//                                        modelDatas.add(modelData);
//                                        break;
//                                    case "预报":
//                                        modelDataY = new ModelData();
//                                        modelDataY.setDataType(dttps[1] + forecastItem.getMonitorType());
//                                        dataListY = new ArrayList<>();
//                                        bdmsYbResultMY = bdms_yb_result_ms.stream().filter(bdms_yb_result_m -> bdms_yb_result_m.getDatacode().equals(point.getMonitorCode())).findAny().orElse(null);
//                                        ybs = bdmsYbResultMY.getDYb().split(",");
//                                        for (j = 0; j < ybs.length; j++) {
//                                            this.calendar.setTime(date3);
//                                            this.calendar.add(10, j + 1);
//                                            Data data = new Data();
//                                            data.setTM(this.format.format(this.calendar.getTime()));
//                                            data.setValue(Double.valueOf(ybs[j]));
//                                            dataListY.add(data);
//                                        }
//                                        maxDataF = dataListY.stream().max(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                        minDataF = dataListY.stream().min(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                        modelDataY.setMaxValue(maxDataF.getValue());
//                                        modelDataY.setMaxTm(maxDataF.getTM());
//                                        modelDataY.setMinValue(minDataF.getValue());
//                                        modelDataY.setMinTm(minDataF.getTM());
//                                        modelDataY.setValues(dataListY);
//                                        modelDatas.add(modelDataY);
//                                        break;
//                                }
//                            }
//                            valueModelC.setValueDatas(modelDatas);
//                            valueModeP.setValueModels(valueModelC);
//                            valueModelPS.add(valueModeP);
//                        }
//                        calData.setCalResults(valueModelPS);
//                        calDatas.add(calData);
//                    }
//                }
//                for (MonitorStation station : forecastItem.getStations()) {
//                    CalData calData = new CalData();
//                    calData.setMainHeading(station.getStationName() + "(" + station.getStationCode() + ")" + forecastItem.getMonitorType() + "");
//                    calData.setSubHeading("作业预报时间："+ bdms_calculatescheme_m.getDtmforecast().substring(0, 19) + "预报根据时间："+ bdms_calculatescheme_m.getDtmstart().substring(0, 19) + "--" + bdms_calculatescheme_m
//                            .getDtmforecast().substring(0, 19));
//                    calData.setForecastStationCode(station.getStationCode());
//                    calData.setStationCode(station.getStationCode());
//                    this.calendar.setTime(this.format.parse(bdms_calculatescheme_m.getDtmforecast()));
//                    this.calendar.add(10, 1);
//                    String forecast = this.format.format(this.calendar.getTime());
//                    for (Point point : station.getPoints()) {
//                        ValueModelP valueModeP = new ValueModelP();
//                        valueModeP.setMonitorName(point.getMonitorName());
//                        valueModeP.setMonitorId(point.getMonitorId());
//                        valueModeP.setMonitorXY(point.getMonitorXY());
//                        valueModeP.setMonitorCode(point.getMonitorCode());
//                        ValueModelC valueModelC = new ValueModelC();
//                        valueModelC.setUnit("mm");
//                        valueModelC.setCalDataType(forecastItem.getMonitorType());
//                        valueModelC.setValueName(forecastItem.getMonitorType());
//                        valueModelC.setOrder(1);
//                        List<ModelData> modelDatas = new ArrayList<>();
//                        String[] dttps = { ", "};
//                        StringBuilder dmn = new StringBuilder();
//                        StringBuilder dyb = new StringBuilder();
//                        for (String dttp : dttps) {
//                            ModelData modelData;
//                            BDMS_YB_RESULT_M bdmsYbResultM;
//                            List<Data> dataList;
//                            String[] mns;
//                            int i;
//                            Data maxData;
//                            Data minData;
//                            ModelData modelDataY;
//                            List<Data> dataListY;
//                            BDMS_YB_RESULT_M bdmsYbResultMY;
//                            String[] ybs;
//                            int j;
//                            Data maxDataF;
//                            Data minDataF;
//                            switch (dttp) {
//                                case "模拟":
//                                    modelData = new ModelData();
//                                    modelData.setDataType(dttps[0] + forecastItem.getMonitorType());
//                                    bdmsYbResultM = bdms_yb_result_ms.stream().filter(bdms_yb_result_m -> bdms_yb_result_m.getDatacode().equals(point.getMonitorCode())).findAny().orElse(null);
//                                    dataList = new ArrayList<>();
//                                    mns = bdmsYbResultM.getDMn().split(",");
//                                    for (i = 0; i < mns.length; i++) {
//                                        this.calendar.setTime(date3);
//                                        this.calendar.add(10, i);
//                                        Data data = new Data();
//                                        data.setTM(this.format.format(this.calendar.getTime()));
//                                        data.setValue(Double.valueOf(mns[i]));
//                                        dataList.add(data);
//                                    }
//                                    maxData = dataList.stream().max(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                    minData = dataList.stream().min(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                    modelData.setMaxValue(maxData.getValue());
//                                    modelData.setMaxTm(maxData.getTM());
//                                    modelData.setMinValue(minData.getValue());
//                                    modelData.setMinTm(minData.getTM());
//                                    modelData.setValues(dataList);
//                                    modelDatas.add(modelData);
//                                    break;
//                                case "预报":
//                                    modelDataY = new ModelData();
//                                    modelDataY.setDataType(dttps[1] + forecastItem.getMonitorType());
//                                    dataListY = new ArrayList<>();
//                                    bdmsYbResultMY = bdms_yb_result_ms.stream().filter(bdms_yb_result_m -> bdms_yb_result_m.getDatacode().equals(point.getMonitorCode())).findAny().orElse(null);
//                                    ybs = bdmsYbResultMY.getDYb().split(",");
//                                    for (j = 0; j < ybs.length; j++) {
//                                        this.calendar.setTime(date3);
//                                        this.calendar.add(10, j + 1);
//                                        Data data = new Data();
//                                        data.setTM(this.format.format(this.calendar.getTime()));
//                                        data.setValue(Double.valueOf(ybs[j]));
//                                        dataListY.add(data);
//                                    }
//                                    maxDataF = dataListY.stream().max(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                    minDataF = dataListY.stream().min(Comparator.comparingDouble(Data::getValue)).orElse(null);
//                                    modelDataY.setMaxValue(maxDataF.getValue());
//                                    modelDataY.setMaxTm(maxDataF.getTM());
//                                    modelDataY.setMinValue(minDataF.getValue());
//                                    modelDataY.setMinTm(minDataF.getTM());
//                                    modelDataY.setValues(dataListY);
//                                    modelDatas.add(modelDataY);
//                                    break;
//                            }
//                        }
//                        valueModelC.setValueDatas(modelDatas);
//                        valueModeP.setValueModels(valueModelC);
//                        valueModelPS.add(valueModeP);
//                    }
//                    calData.setCalResults(valueModelPS);
//                    calDatas.add(calData);
//                }
//                calResult.setCalResult(calDatas);
//                calResults.add(calResult);
//            }
//        }
//        jsonResult.setData(calResults);
//        jsonResult.setSucceeded(true);
//        jsonResult.setStatusCode(Integer.valueOf(200));
//        return jsonResult;
//    }
//}
//
